﻿@model ContactAccount

@{
    Layout = "~/Views/Shared/_LayoutPopup.cshtml";
    var sl = new SL();
    var severities = sl.GetSeverity();
    var listPriorities = sl.GetPriority();
    var secrets = sl.GetSecret(); 
}

@using (Html.BeginForm("ViewCaseDetail", "GroupList", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <input type="hidden" id="case_id" name="case_id" value="@Request["case_id"]"/>
    <div class="service_search_header">
        <div class="service_title">@Multi.AddOperation</div>
    </div>

    <div class="service_search_header2">
        <div class="service_title">@Multi.operation_type</div>
    </div>
    <div class="service_box_table">
        <table id="service_table">
            <tr>
                <td>@Multi.operationType</td>
                <td>
                    <a class="formBtn3 dBlock"  data-block="type"
                       href="@Url.Action("OperatingType")?a=type&case_id=@Request["case_id"]"
                       onclick=" parent.goToPopup2($(this).attr('href'), getForm()); return false; ">@Multi.operationType</a>
                    <span id="block_type"></span> 
                </td>
            </tr>
            <tr>
                <td>@Multi.operatingStatus</td>
                <td><a class="formBtn3 dBlock" data-block="status"
                       href="@Url.Action("OperatingStatus")?a=status&case_id=@Request["case_id"]"
                       onclick=" parent.goToPopup2($(this).attr('href'), getForm()); return false; ">@Multi.operatingStatus</a>
                    <span id="block_status"></span></td>
            </tr>
           
            @*<tr>
                <td>@Multi.essence</td> 
                <td>
                    <textarea name="summary" id="summary" style="height: 40px">@Model.summary</textarea></td>
            </tr>*@
            <tr>
                <td>@Multi.detail</td>
                <td>
                    <textarea name="detail" id="detail" style="height: 60px">@Model.detail</textarea></td>
            </tr>
            <tr>
                <td>@Multi.file_input</td>
                <td>
                    <input type="file" id="case_attachment_input" />
                    <span id="block_case_attachments">
                        @*
            ด้านล่างคือ sourcecode เวลาเลือกไฟล์ใหม่ แล้ว add เข้ามาผ่าน javascript
            <input type="hidden" name="file_content" value=" =" />
            <input type="hidden" name="file_description" value="sadf"/>
            <input type="hidden" name="doc_type_id" value="1"/>
            <input type="hidden" name="doc_no" value="asdfasdf"/>
            <input type="hidden" name="doc_date" value="26/05/2558"/>
            <input type="hidden" name="doc_ref_no" value="sadf"/>
            <input type="hidden" name="doc_ref_date" value="26/05/2558"/>
            <input type="hidden" name="file_name" value="26/05/2558"/>
            <input type="hidden" name="doc_type" value="I"/>
            <div class="blockReAction" id="file_new_attach_1">
                dell_copper_microserver.jpg<span onclick="removeBox1('file_new_attach_1');"></span>
            </div>
                        *@
                    </span></td>
            </tr>
            <tr>
                <td>@Multi.severity_id</td>
                <td>
                    @Html.DropDownListFor(m => m.severity_id, severities, "เลือกชั้นความเร่งด่วน", null)<span style="color:red">*</span>
                </td>
            </tr>
            <tr>
                <td>@Multi.secret_id</td>
                <td>
                    @Html.DropDownListFor(m => m.secret_id, secrets, "เลือกชั้นความลับ", null)<span style="color:red">*</span>
                </td>
            </tr>
            <tr>
                <td>@Multi.priority_id</td>
                <td>
                    @Html.DropDownListFor(m => m.priority_id, listPriorities, "เลือกชั้นความสำคัญ", null)<span style="color:red">*</span>
                </td>
            </tr>
        </table>
    </div>
    <div class="BoxServiceBottom">
        <div class="BoxServiceActionPrev floatL" onclick="parent.$.fn.colorbox.close();">@Multi.Cancel</div>
        <input class="BoxServiceActionNext floatR" type="submit" value="@Multi.save_as" />
        <div class="clear"></div>
    </div>
}
<link rel="stylesheet" type="text/css" href="~/js/colorbox-master/colorbox.css" />
<script src="~/js/colorbox-master/jquery.colorbox-min.js"></script>
<script src="~/js/opm_uploadfile.js"></script>

<style>
    .formBtn3 {
        background-image: url('@Url.Content("~/images/form_button.png")');
        width: 180px;
        height: 24px;
        cursor: pointer;
        color: #726658;
        font-size: 0.85em;
        padding-left: 25px;
        padding-top: 7px;
        display: inline-block;
    }
</style>

<script>
    function getForm() {
        var formJson = new Object();

        formJson.case_id = '@Request["case_id"]';
        formJson.type = $('#type').val();
        formJson.type_text = $('#type_text').val();
        formJson.status = $('#status').val();
        formJson.status_text = $('#status_text').val();
        formJson.org_id = $('#org_id').val();
        formJson.cont_id = $('#cont_id').val();
        formJson.terminal_text = $('#terminal_text').val();
        formJson.summary = $('#summary').val();
        formJson.detail = $('#detail').val();
        formJson.severity_id = $('#severity_id').val();
        formJson.secret_id = $('#secret_id').val();
        formJson.priority_id = $('#priority_id').val();
        formJson.block_case_attachments = $('#block_case_attachments').html();
        return formJson;
    }

    function genDivSelected(type, value, text) {
        var div1 = '<input type="hidden"  id="' + type + '" name="' + type + '" value="' + value + '">' +
            '<input type="hidden"  id="' + type + '_text" name="' + type + '_text" value="' + text + '">' +
                '<div class="blockReAction" data-value="' + value + '">' +
                    text + '<span onclick="removebox(\'' + type + '\', ' + value + ');"></span>' +
                '</div>';
        //alert(div1);
        return div1;
    }
    $(document).ready(function () {
        if (parent.formJson == null) {
            parent.formJson = new Object();
        }
        if (parent.formJson.type) {
            var text2 = genDivSelected('type', parent.formJson.type, parent.formJson.type_text);
            $('#block_type').html(text2);
        }
        if (parent.formJson.status) {
            var text3 = genDivSelected('status', parent.formJson.status, parent.formJson.status_text);
            $('#block_status').html(text3);
        }
        $('#org_id').val(parent.formJson.terminal_org_id);
        $('#cont_id').val(parent.formJson.terminal_officer_id);
        $('#terminal_text').val(parent.formJson.terminal_text);
        $('#summary').val(parent.formJson.summary);
        $('#detail').val(parent.formJson.detail);
        $('#severity_id').val(parent.formJson.severity_id);
        $('#secret_id').val(parent.formJson.secret_id);
        $('#priority_id').val(parent.formJson.priority_id);
        $('#block_case_attachments').html(parent.formJson.block_case_attachments);
    });

</script>